/**
 * Copyright (C) 2012 The SkyTvOS Project
 * <p/>
 * Version     Date           Author
 * ─────────────────────────────────────
 * 2014年12月27日         Root.Lu
 */

package com.coocaa.launcher.statusplugins.net;

import android.content.Context;
import android.view.Gravity;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;

import com.coocaa.launcher.framework.launcherhost.statusbar.StatusBarPluginView;
import com.coocaa.launcher.statusplugins.net.StatusPluginNet.IStatusPluginNet;
import com.coocaa.launcher.statusplugins.net.StatusPluginNet.NET_STATE;
import com.coocaa.x.uipackage.SkinManager;
import com.tianci.appstore.R;
import com.tianci.appstore.utils.SkyConstants;

public class StatusPluginNetView extends StatusBarPluginView implements IStatusPluginNet {
    private ImageView netImage = null;

    public StatusPluginNetView(Context context, String name) {
        super(context, name);
        // TODO Auto-generated constructor stub
        netImage = new ImageView(context);
        FrameLayout.LayoutParams netImageParams = new LayoutParams(SkyConstants.Div(46), SkyConstants.Div(37));
        addView(netImage, netImageParams);
        netImage.setVisibility(View.GONE);
    }

    @Override
    public int getConfigGravity() {
        // TODO Auto-generated method stub
        return Gravity.RIGHT;
    }

    @Override
    public void updateState(final NET_STATE state) {
        // TODO Auto-generated method stub
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                switch (state) {
                    case DISCONNECT: {
                        netImage.setVisibility(View.VISIBLE);
                        SkinManager.getInstance().setBackgroundResource(netImage,
                                R.drawable.sp_net_disconnect);
                        break;
                    }
                    case WIFI: {
                        netImage.setVisibility(View.VISIBLE);
                        SkinManager.getInstance().setBackgroundResource(netImage,
                                R.drawable.sp_net_wifi_connected);
                        break;
                    }
                    case ETHERNET: {
                        netImage.setVisibility(View.VISIBLE);
                        SkinManager.getInstance().setBackgroundResource(netImage,
                                R.drawable.sp_net_ethernet_connected);
                        break;
                    }
                }
            }
        });
    }

    @Override
    public void updateWifiRSSI(int rssi) {
        // TODO Auto-generated method stub

    }
}
